//package com.yxuan.springboot.timer;
//
//import com.yxuan.springboot.model.Information;
//import com.yxuan.springboot.service.CommentService;
//import com.yxuan.springboot.service.InformationService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import java.util.Date;
//import java.util.List;
//
///**
//  * @className: InformationTimer.java
//  * @methodName: InformationTimer
//  * @effect: 资讯文章的定时任务（基于注解方式）
//  * @author: JingxuanFan
//  * @date: 2023/5/19 9:15
//  **/
//
//@Slf4j
//@Component
//@EnableScheduling   // 1.开启定时任务
//@EnableAsync        // 2.开启多线程
//public class InformationTimer {
//
//    @Autowired
//    protected InformationService informationService;
//    @Autowired
//    protected CommentService commentService;
//
//    /**
//      * @className: InformationTimer.java
//      * @methodName: queryInformation
//      * @effect: 每天3时，定时查询更新每篇文章的点赞量，收藏量，分享量，阅读量，评论量等
//      * @author: JingxuanFan
//      * @date: 2023/5/19 10:49
//      **/
//    @Async  //将一个同步方法转换为异步方法(多线程)
//    @Scheduled(cron = "0 0 3 * * ?")  //cron指定执行时间，每天3点执行
//    public void queryInformation(){
//        try{
//            List<String> listId = informationService.queryInformationId();
//            for (String s : listId) {
//                //根据主键Id，查询到资讯数据
//                Information queryInformation = informationService.findTById(s);
//                //0点赞，1收藏，2阅读，3分享
//                queryInformation.setLikeNumber(informationService.queryoperationNum(s,"0"));
//                queryInformation.setCollectionNumber(informationService.queryoperationNum(s,"1"));
//                queryInformation.setReadNumber(informationService.queryoperationNum(s,"2"));
//                queryInformation.setShareNumber(informationService.queryoperationNum(s,"3"));
//                //查询资讯文章的评论数量
//                queryInformation.setCommentNumber(commentService.queryCommentNum(s));
//                //设置修改时间
//                queryInformation.setUpdtime(new Date());
//                //修改/更新文章数据
//                informationService.upd(queryInformation);
//            }
//        }catch (Exception e){
//            log.error(e.getMessage());
//        }
//    }
//
//}
